<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0">

    <link rel="stylesheet" href="{{ url_for('static',filename='css/order.css') }}">
    <link rel="shortcut icon" href="{{ url_for('static', filename='images/hhorder.png') }}">
    <link rel="stylesheet" href="https://unpkg.com/vant/lib/index.css">

    <title>管理</title>

</head>


<body>

    <div id="app">

        <van-nav-bar fixed z-index="10000" title="管理" >
        </van-nav-bar>

        <div class="default-height"></div>

        <van-dialog v-model="show" :before-close="beforeClose">
            <van-field v-model="username" label="用户名" placeholder="请输入用户名"></van-field>
            <van-field v-model="password" type="password" label="密码" placeholder="请输入密码"></van-field>
        </van-dialog>

        <van-list v-model="loading" :finished="finished" >

            <van-cell title="订单管理" is-link @click="clickOrder"></van-cell>
            <van-cell title="办公室管理" is-link @click="clickOffice"></van-cell>
            <van-cell title="版本信息" is-link @click="clickVersion"></van-cell>
        </van-list>


    </div>


    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="https://unpkg.com/vant/lib/vant.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <script>

        $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};

        var app = new Vue({
            el: '#app',
            data() {
                return {
                    office_name: "",
                    office_desc: "",
                    loading: false,
                    finished: true,
                    show: false,
                    username: "",
                    password: ""
                };
            },
            created: function () {
                axios.get($SCRIPT_ROOT + '/loginValidate/').then(function (response) {
                    if (response.data['status'] == 200) {
                        console.log('登录成功');
                        app.show = false;
                        console.log(app.show);
                    } else {
                        app.show = true;
                        console.log('登录失败');
                    }
                });
            },
            methods: {
                clickOrder() {
                    window.location.href = $SCRIPT_ROOT + '/orderManage/';
                },
                clickOffice() {
                    window.location.href = $SCRIPT_ROOT + '/officeManage/';
                },
                clickVersion() {
                    window.location.href = $SCRIPT_ROOT + '/about/';
                },
                beforeClose(action, done) {
                    axios.get($SCRIPT_ROOT + '/pwdValidate/', {
                        params: {
                            username: app.username,
                            password: app.password
                        }
                    }).then(function (response) {
                        if (response.data['status'] == 200) {
                            done();
                        } else {
                            done(false)
                        }
                    });
                }

            }
        });

    </script>




</body>
</html>